from gi.repository import Gtk

def confirm(window, query):
    dia = Gtk.MessageDialog(window, Gtk.DialogFlags.MODAL,
                            Gtk.MessageType.WARNING,
                            Gtk.ButtonsType.YES_NO, query)
    dia.show()
    rtn = dia.run()
    dia.destroy()
    return rtn == Gtk.ResponseType.YES